package jsu.blogger;

import jsu.blogger.mapper.CollectMapper;
import jsu.blogger.pojo.UserFolder;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.time.LocalDateTime;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class testCllection {

    @Autowired
    private CollectMapper collectMapper;
    @Test
    void testDeletePostFromUserFolders(){
        collectMapper.deletePostFromUserFolders(1L,1L);
    }
    @Test
    void testInsert() {
        int checked = collectMapper.checkUserFolder(3L, 1L);
        if (checked > 0) {
            collectMapper.insertFolderPost(3L, 10L);
        }


    }
    @Test
    void testGetDefaultFolderByUserId(){
        System.out.println(collectMapper.getDefaultFolderByUserId(3L));
        // 创建对象
        UserFolder userFolder = new UserFolder();
        userFolder.setUserId(3L);
        userFolder.setFolderDesc("This is my favorite folder.");
        userFolder.setFolderName("My Favorite");
        userFolder.setVisibility(0);
        userFolder.setIsDefault(0);
        userFolder.setLastUpdate(LocalDateTime.now());
       collectMapper.insertUserFolder(userFolder);
        System.out.println(userFolder.getFolderId());
    }

    @Test
   void testGetUserFolders(){
        System.out.println(collectMapper.getUserFolders(1L,10,0));
        collectMapper.resetDefaultFolder(1L);
    }




}
